//
//  DCCustomAlbumCollectionViewCell.swift
//  DCCustomAlbum Customalbum
//
//  Created by point on 2018/6/3.
//  Copyright © 2018年 whiteboard. All rights reserved.
//

import UIKit

class DCCustomAlbumCollectionViewCell: UICollectionViewCell {
    
    lazy var img:UIImageView = UIImageView()
    
    lazy var selectBtn:UIButton = UIButton(type: .custom)
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = UIColor.white
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

extension DCCustomAlbumCollectionViewCell {
    func configModel(modelArr:[DCAlbumModel], index:IndexPath){
       selectBtn.isSelected = modelArr[index.item].selected
       img.contentMode = .scaleToFill
    }
    
    func configModel(model:SchoolDetailCommentModelResourceModel , index:IndexPath) {
        selectBtn.isHidden = true
        img.showImageS(model.path)
    }
}

extension DCCustomAlbumCollectionViewCell {
    fileprivate func setupUI(){
        contentView.addSubview(img)
        contentView.addSubview(selectBtn)
        img.backgroundColor = kColorC2
        img.frame = self.contentView.bounds
      
        img.fastCornerRadius(value: 4)
        selectBtn.snp.makeConstraints { (make) in
            make.size.equalTo(CGSize(width: 20, height: 20))
            make.top.equalTo(contentView).offset(10)
            make.right.equalTo(contentView).inset(10)
        }
        
        img.clipsToBounds = true
        selectBtn.setImage(UIImage(named: "photo_select"), for: .normal)
        selectBtn.setImage(UIImage(named: "photo_selected"), for: .selected)
    }
}
